# Boneless I/O #

Using the Coroutines TS to implement elegant I/O abstractions.

## Example ##

```c++
#include "bio.h"

using bio::async;
using bio::bytes;
using bio::TcpServer;
using bio::TcpClient;

async<void> echoserver_client(TcpClient client) {
    bytes b = co_await client.read(1024);
    co_await client.write(b);
    client.shutdown();
    co_return;
}

async<void> echoserver_main(uint16_t port) {
    TcpServer serv{port, [](TcpClient client, struct sockaddr_in6 addr, TcpServer& server) {
        bio::background(echoserver_client(std::move(client)));
    }};
    bio::signal(SIGINT, [&serv]() { serv.shutdown(); });
    co_await serv.wait_shutdown();
    co_return;
}

int main() {
    bio::init();
    bio::run(echoserver_main(1337));
    bio::destroy();
    return 0;
}
```

## Building ##

You need CMake and latest Clang. Or in the case that some other compiler gets support for the
coroutines TS, and supports `coroutine_handle<> await_suspend()` then hopefully that one.

```
./scripts/setup.sh
cd build
make
```
